package com.boil.qz.safekavass.web.request.param;

import com.boil.util.Constants;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

/**
 * Created by ChenYong on 2017-07-12.
 * <br>
 * 添加资源的请求参数。
 */
public class ResourceUpdateParam extends IdParam {
    /**
     * 父资源 ID
     */
    @NotNull(message = "父资源ID不能为空")
    @Range(min = Constants.VALUE_L_1, max = Long.MAX_VALUE, message = "父资源ID在1至9223372036854775807之间")
    private Long parentId;
    /**
     * 资源名称
     */
    @NotBlank(message = "资源名称不能为空")
    @Length(min = Constants.VALUE_1, max = Constants.VALUE_50, message = "资源名称的长度在1至50个字之间")
    @Pattern(regexp = Constants.CHINESE_2_RE, message = "资源名称由汉字、数字（0-9）、字母（a-z, A-Z）、下划线（_）、斜杠（/）组成")
    private String resourceName;
    /**
     * 资源图标
     */
    @Pattern(regexp = Constants.ICONFONT_EMPTY_RE, message = "资源" + Constants.ICONFONT_RE_MSG)
    private String resourceIcon;
    /**
     * 资源 URL
     */
    @Pattern(regexp = Constants.URL_ONLY_EMPTY_RE, message = "资源" + Constants.URL_RE_MSG)
    private String resourceUrl;
    /**
     * 权限代码
     */
    @NotBlank(message = "权限代码不能为空")
    @Length(min = Constants.VALUE_1, max = Constants.VALUE_50, message = "权限代码的长度在1至50个字符之间")
    @Pattern(regexp = Constants.PERMISSION_RE, message = Constants.PERMISSION_RE_MSG)
    private String permissionCode;

    /**
     * 默认构造器。
     */
    public ResourceUpdateParam() {
        super();
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public String getResourceName() {
        return resourceName;
    }

    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }

    public String getResourceIcon() {
        return resourceIcon;
    }

    public void setResourceIcon(String resourceIcon) {
        this.resourceIcon = resourceIcon;
    }

    public String getResourceUrl() {
        return resourceUrl;
    }

    public void setResourceUrl(String resourceUrl) {
        this.resourceUrl = resourceUrl;
    }

    public String getPermissionCode() {
        return permissionCode;
    }

    public void setPermissionCode(String permissionCode) {
        this.permissionCode = permissionCode;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer("ResourceUpdateParam{");
        sb.append("parentId=").append(parentId);
        sb.append(", resourceName='").append(resourceName).append('\'');
        sb.append(", resourceIcon='").append(resourceIcon).append('\'');
        sb.append(", resourceUrl='").append(resourceUrl).append('\'');
        sb.append(", permissionCode='").append(permissionCode).append('\'');
        sb.append(", id=").append(id);
        sb.append('}');
        return sb.toString();
    }
}